CFLAGS = -Wall -fpic -coverage -lm

tests: testPlayCard.c testDiscardCard.c testSystem.c dominion.o rngs.o
	gcc -o testPlayCard -g testPlayCard.c dominion.o rngs.o $(CFLAGS)
	gcc -o testDiscardCard -g testDiscardCard.c dominion.o rngs.o $(CFLAGS)
	gcc -o testSystem -g testSystem.c dominion.o rngs.o $(CFLAGS)

testdominion.out: testdominion.c dominion.o rngs.o
	echo "Results for running random test on a game of Dominion:" >> testdominion.out
	gcc -o testdominion -g testdominion.c dominion.o rngs.o $(CFLAGS)
	testdominion >> testdominion.out
	gcov -b testdominion.c >> testdominion.out
	gcov -b dominion.c >> testdominion.out
	rm -f dominion.c.gcov dominion.gcda

randomtests.out: randomtestadventurer.c randomtestcard.c dominion.o rngs.o

	echo "Results for running Random Tests on Adventurer:" >> randomtestadventurer.out
	gcc -o randomtestadventurer -g randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	randomtestadventurer >> randomtestadventurer.out
	gcov -b dominion.c >> randomtestadventurer.out
	rm -f dominion.c.gcov dominion.gcda

	echo "Results for running Random Tests on Sea Hag:" >> randomtestcard.out
	gcc -o randomtestcard -g randomtestcard.c dominion.o rngs.o $(CFLAGS)
	randomtestcard >> randomtestcard.out
	gcov -b dominion.c >> randomtestcard.out
	rm -f dominion.c.gcov dominion.gcda

unittestresults.out: unittest1.c unittest2.c unittest3.c unittest4.c cardtest1.c cardtest2.c cardtest3.c cardtest4.c dominion.o rngs.o

	echo "Results for running Unit Tests:" >> unittestresults.out

	echo "unittest1.c:" >> unittestresults.out
	gcc -o unittest1 -g unittest1.c dominion.o rngs.o $(CFLAGS)
	unittest1 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "unittest2.c:" >> unittestresults.out
	gcc -o unittest2 -g unittest2.c dominion.o rngs.o $(CFLAGS)
	unittest2 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "unittest3.c:" >> unittestresults.out
	gcc -o unittest3 -g unittest3.c dominion.o rngs.o $(CFLAGS)
	unittest3 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "unittest4.c:" >> unittestresults.out
	gcc -o unittest4 -g unittest4.c dominion.o rngs.o $(CFLAGS)
	unittest4 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "cardtest1.c:" >> unittestresults.out
	gcc -o cardtest1 -g cardtest1.c dominion.o rngs.o $(CFLAGS)
	cardtest1 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "cardtest2.c:" >> unittestresults.out
	gcc -o cardtest2 -g cardtest2.c dominion.o rngs.o $(CFLAGS)
	cardtest2 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "cardtest3.c:" >> unittestresults.out
	gcc -o cardtest3 -g cardtest3.c dominion.o rngs.o $(CFLAGS)
	cardtest3 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

	echo "cardtest4.c:" >> unittestresults.out
	gcc -o cardtest4 -g cardtest4.c dominion.o rngs.o $(CFLAGS)
	cardtest4 >> unittestresults.out
	gcov dominion.c >> unittestresults.out
	rm -f dominion.c.gcov dominion.gcda

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard unittestresults.out randomtests.out testdominion.out tests

clean:
	rm -f *.o testSystem systemResults.out testDiscardCard testPlayCard gameResults.out testdominion testdominion.out randomtestcard randomtestcard.out randomtestadventurer randomtestadventurer.out unittestresults unittestresults.out playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe unittest1 unittest1.exe unittest2 unittest2.exe unittest3 unittest3.exe unittest4 unittest4.exe cardtest1 cardtest1.exe cardtest2 cardtest2.exe cardtest3 cardtest3.exe cardtest4 cardtest4.exe *.gcov *.gcda *.gcno *.so
